<template>
	<view>
		<view-grid ref="grid" :index="true" :options="options" v-if="show">
			<!-- 自定义slot -->
			<view @click="viewClick" slot="gridHeader" class="grid-header">
				{{ gridHeaderText }}
			</view>
		</view-grid>
		<!-- <addPage :options="options" :biaoming="'q_operations_recycle'" :currentAction="'Add'" :ID="'Operations_recycle'" :zibiaoming="'q_operations_recycle_not'" v-else></addPage> -->
	</view>
</template>

<script>
//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import extend from './q_operations_recycleExtend.js';
import options from './q_operations_recycleOptions.js';
import detailOptions from '../q_operations_recycleList/q_operations_recycleListOptions.js';
export default {
	data() {
		let _options = options();
		_options.extend = extend;
		_options.detailOptions = detailOptions();
		return {
			gridHeaderText: '', //随便输入字符后可以显示出来
			options: _options,
			time: null,
			show: true //控制主页面还是新建编辑
		};
	},
	onLoad() {
		this.$store.commit('clearOperations_recycleList');
		// this.show = true;
			this.time = setInterval(() => {
				console.log('定时器');
				if (this.$refs.grid) {
					if (this.$refs.grid.fabButtons) {
						clearInterval(this.time);
						this.$refs.grid.fabButtons.forEach((item) => {
							if (item.name == '添加') {
								item.onClick = () => {
									// this.show = false;
									const optionsObj = {
										// editFormFields: this.options.editFormFields,
										editFormOptions: this.options.editFormOptions,
										detailColumns: this.options.detailOptions.columns,
										detailtable: this.options.table
									};
									uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
									uni.navigateTo({
										url: '/pages/addPage/addPage?biaoming=q_operations_recycle&currentAction=Add&ID=Operations_recycle&zibiaoming=q_operations_recycle_not'
									});
								};
							}
						});
					}
					this.$refs.grid.refresh()//刷新
				}
			}, 500);
		
	},
	onShow() {
		// this.$refs.grid.refresh()
	},
	onHide() {
		clearInterval(this.time);
	},
	methods: {
		viewClick() {
			//获取生成页面grid的对象
			console.log(this.$refs.grid.searchFormFields);
		}
	}
};
</script>

<style></style>
